load("@rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "collection",
    srcs = [
        "doc.go",
        "errors.go",
        "etcd_collection.go",
        "postgres_collection.go",
        "postgres_listener.go",
        "postgres_schema.go",
        "range.go",
        "test.pb.go",
        "test.pb.validate.go",
        "test.pb.zap.go",
        "transaction.go",
        "types.go",
    ],
    importpath = "github.com/pachyderm/pachyderm/v2/src/internal/collection",
    visibility = ["//src:__subpackages__"],
    deps = [
        "//src/internal/backoff",
        "//src/internal/dbutil",
        "//src/internal/errors",
        "//src/internal/errutil",
        "//src/internal/log",
        "//src/internal/pachsql",
        "//src/internal/pctx",
        "//src/internal/tracing",
        "//src/internal/uuid",
        "//src/internal/watch",
        "//src/version",
        "@com_github_jackc_pgerrcode//:pgerrcode",
        "@com_github_jmoiron_sqlx//:sqlx",
        "@com_github_lib_pq//:pq",
        "@io_etcd_go_etcd_api_v3//mvccpb",
        "@io_etcd_go_etcd_api_v3//v3rpc/rpctypes",
        "@io_etcd_go_etcd_client_v3//:client",
        "@org_golang_google_grpc//codes",
        "@org_golang_google_grpc//status",
        "@org_golang_google_protobuf//proto",
        "@org_golang_google_protobuf//reflect/protoreflect",
        "@org_golang_google_protobuf//runtime/protoimpl",
        "@org_golang_google_protobuf//types/known/anypb",
        "@org_golang_x_sync//errgroup",
        "@org_uber_go_zap//:zap",
        "@org_uber_go_zap//zapcore",
    ],
)

go_test(
    name = "collection_test",
    srcs = [
        "collection_test.go",
        "etcd_collection_test.go",
        "postgres_collection_test.go",
        "watch_test.go",
    ],
    pure = "on",
    deps = [
        ":collection",
        "//src/internal/client",
        "//src/internal/dbutil",
        "//src/internal/dockertestenv",
        "//src/internal/errors",
        "//src/internal/errutil",
        "//src/internal/pachsql",
        "//src/internal/pctx",
        "//src/internal/ppsdb",
        "//src/internal/require",
        "//src/internal/testetcd",
        "//src/internal/testpachd/realenv",
        "//src/internal/testutil/random",
        "//src/internal/uuid",
        "//src/internal/watch",
        "//src/pfs",
        "//src/pps",
        "//src/proxy",
        "@io_etcd_go_etcd_client_v3//:client",
        "@org_golang_google_protobuf//proto",
        "@org_golang_google_protobuf//types/known/wrapperspb",
        "@org_golang_x_sync//errgroup",
    ],
)

filegroup(
    name = "protos",
    srcs = glob(["*.proto"]),
    visibility = ["//src:__pkg__"],
)
